home *** CD-ROM | disk | FTP | other *** search
- // globals
- // window arguments defined here, but may not be used.
- // mainly to test & explain valid arguments.
-
- /**
- var invitedScreenNames = window.arguments[0]
- var inviteToExistingWindow=window.arguments[1]
- var inviteMode=window.arguments[2]
- var inviteProposalObj=window.arguments[3]
- **/
-
- inviteArgsObj = window.arguments[0];
-
- invitedScreenNames = inviteArgsObj.invitedScreenNames;
- inviteToExistingWindow = inviteArgsObj.inviteToExistingWindow;
- inviteMode = inviteArgsObj.inviteMode;
- inviteMsg = inviteArgsObj.invitationmsg;
- inviteProposalObj = inviteArgsObj.inviteProposalObj;
- inviteProposalScreenName = inviteArgsObj.inviteProposalScreenName;
- inviteToExistingRoom = inviteArgsObj.inviteToExistingRoom;
-
- // for incoming chat invitation
- var incomingChatScreenName = inviteProposalScreenName;
- var incomingChatWarningLevel;
- var incomingChatRoomName;
- var incomingChatRoomDate;
- var incomingChatRoomInviteMsg;
- var incomingChatRoom;
-
- var ChatManagerCallBack = new Object();
- var RoomCreationTimeStamp = null;
-
- ChatManagerCallBack.OnRequestRoomComplete = function(roomName,chatRoomObj)
- {
- incomingChatRoom=chatRoomObj;
- incomingChatRoomName = chatRoomObj.GetName();
- document.getElementById("chatRendezvousRoomName001").setAttribute("value",incomingChatRoomName);
- }
-
- ChatManagerCallBack.OnRequestRoomError = function(roomName,errMsg)
- {
- dump("OnRequestRoomError: there was an error \n");
- }
-
- myExecutionCallback = new Object();
- myExecutionCallback.ExecuteIfReady = function()
- {
- // get chatroom and callbacks
- inviteProposalObj.Accept();
- aimChatManager().RequestProposedRoom(ChatManagerCallBack, inviteProposalObj);
- }
-
- function setButtons(okLabel, cancelLabel, okTooltip, cancelTooltip)
- {
- var buttons = document.getElementsByTagName("button");
- for (i=0;i<buttons.length;i++) {
- //dump("buttons["+i+"] = " + buttons[i] + "," + buttons[i].getAttribute('id') + "\n");
- if (okLabel && buttons[i].getAttribute('id') == "ok") {
- buttons[i].label = okLabel;
- }
- else if (cancelLabel && buttons[i].getAttribute('id') == "cancel") {
- buttons[i].label = cancelLabel;
- }
- /** killing tooltips for ok cancel for now since they are text
- if(okTooltip && buttons[i].getAttribute('id') == "ok") {
- buttons[i].setAttribute('tooltip','aTooltip');
- buttons[i].setAttribute('tooltiptext', okTooltip);
- }
-
- if(cancelTooltip && buttons[i].getAttribute('id') == "cancel") {
- buttons[i].setAttribute('tooltip','aTooltip');
- buttons[i].setAttribute('tooltiptext', cancelTooltip);
- }
- **/
- }
- }
-
- function chatInviteBuddyOnWinLoad(){
- doSetOKCancel(chatInviteBuddyCmdInvite, onCancel);
-
- /* VISHY - this is a performance optimization.
- Since chat needs time to get ready, this tells it to
- get ready, well before we actually use it */
- aimChatManager().ExecuteIfReady(null);
-
- dump("chatInviteBuddyOnWinLoad\n");
-
- if(inviteMode && inviteMode=="incomingchat"){
- setButtons(aimString('chat.YesButton'), aimString('chat.NoButton'), aimString('accept.tooltip'), aimString('decline.tooltip'));
-
- dump("incoming chat\n");
-
- doSetOKCancel(chatInviteBuddyCmdAcceptRendezvous, chatInviteBuddyCmdDeclineRendezvous);
-
- document.getElementById("cibdeck001").setAttribute("selectedIndex",2)
-
- // incomingChatScreenName = "testscreename";
- incomingChatWarningLevel = " " + aimString("chat.WarningLevel").replace(/%Level%/, inviteProposalObj.GetProposer().GetWarningPercent());
- incomingChatRoomName = " ";
- incomingChatRoomDate= new Date();
-
- // use international date format
- try {
- var IDateTime = Components.classes["@mozilla.org/intl/scriptabledateformat;1"].createInstance();
- var dateFormatter = IDateTime.QueryInterface(Components.interfaces.nsIScriptableDateFormat);
-
- var curYear = incomingChatRoomDate.getYear() + 1900;
- var curMonth = incomingChatRoomDate.getMonth() + 1;
- var curDay = incomingChatRoomDate.getDate();
- var curHours = incomingChatRoomDate.getHours();
- var curMinutes = incomingChatRoomDate.getMinutes();
- var curSeconds = incomingChatRoomDate.getSeconds();
- dump("stuff: " + curYear + " " + curMonth + " " +curDay + " " +curHours + " " +curMinutes + " " +curSeconds + "\n");
-
- dateTimeStr = dateFormatter.FormatDateTime("",
- Components.interfaces.nsIScriptableDateFormat.dateFormatLong,
- Components.interfaces.nsIScriptableDateFormat.timeFormatSeconds,
- curYear,curMonth,curDay,curHours,curMinutes,curSeconds);
- incomingChatRoomDate = dateTimeStr;
- dump("Using FormatDateTime: " + incomingChatRoomDate + "\n");
- }
- catch(e) {
- dump("Error using FormatDateTime: " + e + "\n");
- }
-
- incomingChatRoomInviteMsg = inviteProposalObj.GetInvitation();
- document.getElementById("chatRendezvousScreenName001").setAttribute("value",incomingChatScreenName);
- document.getElementById("chatRendezvousScreenName002").setAttribute("label",incomingChatScreenName);
- document.getElementById("chatRendezvousScreenName003").setAttribute("value",incomingChatScreenName);
- document.getElementById("chatRendezvousWarningLevel001").setAttribute("value",incomingChatWarningLevel);
- document.getElementById("chatRendezvousRoomName001").setAttribute("value",incomingChatRoomName);
- document.getElementById("chatRendezvousChatRoomDate").setAttribute("value",incomingChatRoomDate);
- document.getElementById("chatRendezvousInvitationMsg").setAttribute("value", incomingChatRoomInviteMsg);
-
- //XXXVISHY - unfortunately you need to get the Chat Room
- // in order to find its name ;-)
- aimChatManager().ExecuteIfReady(myExecutionCallback);
- }
-
- if(inviteMode && inviteMode=="outgoingchat")
- {
- dump("outgoing chat\n");
- setButtons(aimString('chat.InviteButton'), null, aimString('chatInvite.tooltip'), aimString('chatCancel.tooltip'));
-
- document.getElementById("cibdeck001").setAttribute("selectedIndex",1)
-
- if (invitedScreenNames && invitedScreenNames != ""){}
- else
- {
- invitedScreenNames = "";
- document.getElementById("invitedscreennames").focus();
- }
-
- document.getElementById("invitedscreennames").value = invitedScreenNames;
- if(inviteMsg)
- document.getElementById("invitationmsg").value=inviteMsg;
- else
- document.getElementById("invitationmsg").value=aimString("chat.JoinMe");
-
- if(inviteToExistingRoom)
- {
- dump("inviteToExisting Room\n");
- document.getElementById("buddychatroomname").value = inviteToExistingRoom;
- document.getElementById("buddychatroomname").setAttribute("readonly","true");
- }
- else
- chatPreFillRoomName();
- }
-
- }
-
- function onCancel(){
- return true;
- }
-
- function chatInviteBuddyOnWinUnLoad(){
- //window.close();
- }
-
- function chatInviteBuddyCmdInvite(){
- dump("chatInviteBuddyCmdIncite\n");
- document.getElementById("cibdeck001").setAttribute("selectedIndex",3)
-
- // document.getElementById("cibdeck").setAttribute("id",1);
- if(!inviteToExistingWindow){
- // var invitedScreenNames = document.getElementById("invitedscreennames").getAttribute("value");
- var invitedScreenNames = document.getElementById("invitedscreennames").value;
- // var chatRoomName = document.getElementById("buddychatroomname").getAttribute("value");
- var chatRoomName = document.getElementById("buddychatroomname").value;
- dump("setting ChatRoomName "+chatRoomName+"\n")
- // var chatMsg = document.getElementById("invitationmsg").getAttribute("value");
- var chatMsg = document.getElementById("invitationmsg").value;
- dump("screenNames "+invitedScreenNames+"\n");
-
- // just send one argument to window.openDialog - but build an object. This way you dont have to worry about
- // keeping track of the argument's order.
- chatContentArgs = new Object();
- chatContentArgs.invitedScreenNames = invitedScreenNames;
- chatContentArgs.chatRoomName = chatRoomName;
- chatContentArgs.chatMsg = chatMsg;
- // not incoming chat
- chatContentArgs.incomingChat = false;
- chatContentArgs.incomingChatInviteProposalScreenName = ''
- chatContentArgs.incomingChatInviteProposalObj=null
- chatContentArgs.incomingChatRoom=null;
- dump("about to openDialog chatContent.xul\n");
- window.openDialog("chrome://aim/content/chatContent.xul","","chrome,all,dialog=no",chatContentArgs);
-
-
- //window.close();
-
- }
- else{
- dump("myOpener:"+window.opener+"\n")
- // window.opener.chatContentInviteMany(document.getElementById("invitedscreennames").getAttribute("value"),document.getElementById("invitationmsg").getAttribute("value"))
- window.opener.chatContentInviteMany(document.getElementById("invitedscreennames").value,document.getElementById("invitationmsg").value);
- // window.opener.chatMsg = document.getElementById("invitationmsg").getAttribute("value")
- window.opener.chatMsg = document.getElementById("invitationmsg").value;
- window.close();
- }
-
- }
-
- function cmdChatIncomingWarn()
- {
- var warnUserArgs = new Object();
- warnUserArgs.screenName = incomingChatScreenName;
-
- window.openDialog("chrome://aim/content/WarnUser.xul","_blank", "chrome,dialog=no",warnUserArgs)
- }
-
- function cmdChatIncomingBlock()
- {
- var pIAimPrivacy = aimPrivacy();
- if ( !pIAimPrivacy )
- return false;
-
- pIAimPrivacy.BlockUser( incomingChatScreenName );
- inviteProposalObj.Reject();
- window.close();
- }
-
- function cmdChatIncomingIM()
- {
- aimIMInvokeIMForm(incomingChatScreenName);
- }
-
- function cmdChatIncomingInfo()
- {
-
- }
-
- function chatInviteBuddyCmdDeclineRendezvous()
- {
- inviteProposalObj.Reject();
- window.close();
- }
-
- function chatInviteBuddyCmdAcceptRendezvous(){
- document.getElementById("cibdeck001").setAttribute("selectedIndex",3)
-
-
- // code to accept rendezvous here
- var invitedScreenNames = "";
- var chatRoomName=incomingChatRoomName
- var chatMsg = "";
-
-
- // just send one argument to window.openDialog - but build an object. This way you dont have to worry about
- // keeping track of the argument's order.
- chatContentArgs = new Object();
- chatContentArgs.invitedScreenNames = invitedScreenNames;
- chatContentArgs.chatRoomName = chatRoomName;
- chatContentArgs.chatMsg = chatMsg;
- dump('chatInviteBuddy.js :try to accept the proposal \n');
- // inviteProposalObj.Accept();
- // yes incoming chat
- chatContentArgs.incomingChat = true;
- chatContentArgs.incomingChatInviteProposalScreenName = inviteProposalScreenName;
- chatContentArgs.incomingChatInviteProposalObj=inviteProposalObj
- chatContentArgs.incomingChatRoom=incomingChatRoom;
- window.openDialog("chrome://aim/content/chatContent.xul","","chrome,all,dialog=no",chatContentArgs);
-
-
- }
-
-
- function chatPreFillRoomName(){
- if(aimManager()){
- // depends on AimSession.js
- var currentScreenName = aimSessionCurrentScreenName()
- // does this need to be instead 001 , 002, 003 ?
- var someRandomNumber = Math.ceil(Math.random()*100);
- // document.getElementById("buddychatroomname").setAttribute("value",currentScreenName+" chat "+someRandomNumber);
- document.getElementById("buddychatroomname").value=currentScreenName+" chat "+someRandomNumber;
-
- }
-
- }
-
-